package com.ruoyi.abuwx.controller;

import com.ruoyi.abuwx.domain.AbuwxQuestionCategory;
import com.ruoyi.abuwx.service.IAbuwxQuestionCategoryService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 题库管理Controller
 * 
 * @author tang
 * @date 2022-07-02
 */
@RestController
@RequestMapping("/abuwx/AbuwxQuestionCategory")
public class AbuwxQuestionCategoryController extends BaseController
{
    @Autowired
    private IAbuwxQuestionCategoryService abuwxQuestionCategoryService;

    /**
     * 查询题库管理列表
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxQuestionCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(AbuwxQuestionCategory abuwxQuestionCategory)
    {
        startPage();
        List<AbuwxQuestionCategory> list = abuwxQuestionCategoryService.selectAbuwxQuestionCategoryList(abuwxQuestionCategory);
        return getDataTable(list);
    }

    /**
     * 导出题库管理列表
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxQuestionCategory:export')")
    @Log(title = "题库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AbuwxQuestionCategory abuwxQuestionCategory)
    {
        List<AbuwxQuestionCategory> list = abuwxQuestionCategoryService.selectAbuwxQuestionCategoryList(abuwxQuestionCategory);
        ExcelUtil<AbuwxQuestionCategory> util = new ExcelUtil<AbuwxQuestionCategory>(AbuwxQuestionCategory.class);
        util.exportExcel(response, list, "题库管理数据");
    }

    /**
     * 获取题库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxQuestionCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(abuwxQuestionCategoryService.selectAbuwxQuestionCategoryById(id));
    }

    /**
     * 新增题库管理
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxQuestionCategory:add')")
    @Log(title = "题库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AbuwxQuestionCategory abuwxQuestionCategory)
    {
        return toAjax(abuwxQuestionCategoryService.insertAbuwxQuestionCategory(abuwxQuestionCategory));
    }

    /**
     * 修改题库管理
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxQuestionCategory:edit')")
    @Log(title = "题库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AbuwxQuestionCategory abuwxQuestionCategory)
    {
        return toAjax(abuwxQuestionCategoryService.updateAbuwxQuestionCategory(abuwxQuestionCategory));
    }

    /**
     * 删除题库管理
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxQuestionCategory:remove')")
    @Log(title = "题库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(abuwxQuestionCategoryService.deleteAbuwxQuestionCategoryByIds(ids));
    }
}
